package com.sumainfor.pc.gmio.service.impl;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.gmio.dao.MktFeign.HouOwmemberMapper;
import com.sumainfor.pc.gmio.dao.MktFeign.HousingOwcontactMapper;
import com.sumainfor.pc.gmio.feign.ZuulFeign.ZuulFeign;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/1/17 20:42
 * @Description:
 */
@Service
public class HouOwmemberSerive {

    @Autowired
    HouOwmemberMapper houOwmemberMapper;

    @Autowired
    ZuulFeign ZuulFeign;

    /**
     * 功能描述:
     * 根据房源编号查询业主成员变更记录
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/1/17 16:57
     */
    public List<Map<String,Object>> getHouOwmemberList(Map<String,Object>params){
        List<Map<String,Object>>getHouOwmemberList= houOwmemberMapper.getHouOwmemberList(params);
        if(getHouOwmemberList.size()>0){
            for(Map<String,Object> map:getHouOwmemberList){
                JsonResult jsonResult=ZuulFeign.getUserMap(map);
                if(jsonResult.isSuccess()==true){
                    Map<String,Object>User=(Map<String,Object>)jsonResult.getResult();
                    if(MapUtils.isNotEmpty(User)){
                        map.putAll(User);
                    }
                }
            }
        }
        return getHouOwmemberList;
    }

    /**
     * 功能描述:
     * 根据房源编号查询查询业主成员变更记录总数
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/1/17 16:57
     */
    public Integer getHouOwmemberListCount(Map<String,Object>params){
        Integer getHouOwmemberListCount=houOwmemberMapper.getHouOwmemberListCount(params);
        return getHouOwmemberListCount;
    }
}
